package com.heima.delete;

import com.heima.domain.GetIndex;
import com.heima.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class DeleteStudent {
    public void deleteStudent(ArrayList<Student> list) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入要删除的学生学号:");
            String did = sc.next();
            GetIndex getIndex = new GetIndex();
            int index = getIndex.getIndex(list, did);
            if (index == -1) {
                System.out.println("查无此人请重新输入!");
            } else {
                list.remove(index);
                System.out.println("删除成功");
                break;
            }
        }
    }
}
